{template 'common/header'}
{php echo $this -> set_tabbar($action, 4);}
<div class="main">
    <form action="" method="post" class="form-horizontal form">
        <div class="panel panel-default">
            <div class="panel-heading">
                {$title}SN码
            </div>
            <div class="table-responsive panel-body">
                <table class="table table-hover">
                    <thead class="navbar-inner">
                    <tr>
                        <th style="width:16%;">名称</th>
                        <th style="width:13%;">会员卡</th>
                        <th style="width:13%;">SN码</th>
                        <th style="width:10%;">派发时间</th>
                        <th style="width:10%;">使用时间</th>
                        <th style="width:14%;">消费门店/店员</th>
                        <th style="width:8%;">消费金额</th>
                        <th style="width:8%;">状态</th>
                        <th style="width:8%;">操作</th>
                    </tr>
                    </thead>
                    <tbody id="level-list">
                    {loop $list $item}
                    <tr>
                        <td>{$coupon_list[$item['pid']]['title']}</td>
                        <td>
                            {$item['cardnumber']}
                        </td>
                        <td>{$item['sncode']}</td>
                        <td style="white-space:normal;">{php echo date('Y-m-d <br/> H:i:s', $item['winningtime'])}</td>
                        <td style="white-space:normal;">{if !empty($item['usetime'])}{php echo date('Y-m-d <br/> H:i:s', $item['usetime'])}{/if}</td>
                        <td>
                            <font color="green">
                            {if $item['storeid']==0}
                                门店总部
                            {else}
                                {$stores[$item['storeid']]['title']}/
                                {$password[$item['passwordid']]['username']}
                            {/if}
                            </font>
                        </td>
                        <td>{$item['money']}</td>
                        <td>{if $item['status'] == 0}<span class="label label-info" style="background:#56af45;">未使用</span>{else}<span class="label label-default">已使用</span>{/if}</td>
                        <td>
                            {if $item['status'] == 0}
                            <a class="btn btn-default btn-sm use" data-codeid="{$item['id']}" href="javascript:void(0)" title="立即使用"><i class="icon-check"></i>立即使用</a>
                            {/if}
                        </td>
                    </tr>
                    {/loop}
                    </tbody>
                </table>
            </div>
        </div>
    </form>
    {$pager}
    <div id="modal-module-menus-recharge"  class="modal fade" tabindex="-1">
        <div class="modal-dialog" style='width: 520px;'>
            <div class="modal-content">
                <div class="modal-header"><button aria-hidden="true" data-dismiss="modal" class="close" type="button">×</button><h3>SN码操作</h3></div>
                <div class="modal-body">
                    <form id="frmPrice" action="{php echo $this->createWebUrl('UseSncodeAdmin')}" method="post" class="form-horizontal">
                        <input type="hidden" name="pid" value="{$pid}">
                        <input type="hidden" name="type" value="{$type}">
                        <input type="hidden" id="snid" name="snid" value="0">
                        {if $type != 3}
                        <div class="form-group">
                            <label class="col-xs-12 col-sm-3 col-md-2 control-label">消费金额</label>
                            <div class="col-sm-9">
                                <div class="input-append">
                                    <input type="text" placeholder="金额" name="money" id="money" class="form-control" data-rule-required="true" data-rule-number="true">
                                    <span class="add-on"><i class="icon-cny"></i></span>
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-xs-12 col-sm-3 col-md-2 control-label">消费类型</label>
                            <div class="col-sm-9">
                                <select name="paytype" id="paytype" class="form-control" >
                                    <option value="0">请选择消费类型</option>
                                    <option value="1">现金消费</option>
                                    <option value="2">余额消费</option>
                                </select>
                            </div>
                        </div>
                        {/if}
                        <div class="form-group">
                            <label class="col-xs-12 col-sm-3 col-md-2 control-label"></label>
                            <div class="col-sm-9">
                                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                                <button type="submit" class="btn btn-primary">提交</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>

</div>
<script type="text/javascript">
    $(function () {
        $("tr").delegate(".use", "click", function () {
            $("#price").val("");
            $("#snid").val($(this).attr("data-codeid"));
            $("#modal-module-menus-recharge").modal();
        });
    });
</script>
{template 'common/footer'}